package leecode

func validateBookSequences(putIn []int, takeOut []int) bool {
	assist := make([]int, 0)
	index := 0
	for i := 0; i < len(putIn); i++ {
		//元素入栈
		assist = append(assist, putIn[i])
		for len(assist) > 0 && assist[len(assist)-1] == takeOut[index] {
			//元素出栈
			assist = assist[:len(assist)-1]
			index++
		}
	}
	return len(assist) == 0
}
